/*
 * Copyright (c) China Telecom Cloud Technology Co., Ltd. 2024-2025. All rights reserved.
 */
#ifndef COMMON_H
#define COMMON_H

#include <stdint.h>
#include <vector>
#include <map>


//! 全局错误宏
#define KVC_OK (0)
#define KVC_ERR_INVALID_ARG  (0x1)
#define KVC_ERR_MEMFUNC_FAIL (0x2)
#define KVC_ERR_MEM_REDAONLY (0x3)
#define KVC_ERR_NOT_SUPPORT  (0x4)
#define KVC_ERR_FILEOP_FAIL  (0x5)
#define KVC_ERR_NOT_FOUND    (0x6)
#define KVC_ERR_NOMEM        (0x7)
#define KVC_ERR_INTERNAL     (0x8)
#define KVC_ERR_PART_SEAL    (0x9)
#define KVC_ERR_NOT_FILLED   (0xa)

#define MICROSECONDS_PER_SECOND      1000000   // 每秒微秒数
#define MICROSECONDS_PER_MILLISECOND 1000      // 每毫秒微妙数
#define PERCENTAGE_MULTIPLIER        100.0     // 百分比乘子


//! 自定义类型(缩短代码长度， >= C++11)
template<typename T>
using VecT = std::vector<T>;


template<typename T>
using MatrixT = std::vector<std::vector<T>>;


template<typename T>
using uInt32MapT = std::map<uint32_t, T>;


template<typename T>
using int32MapT = std::map<int32_t, T>;


template<typename T>
using uInt64MapT = std::map<uint64_t, T>;


template<typename T>
using int64MapT = std::map<int64_t, T>;



/**
 *! @brief 返回当前时间（从 1970-01-01 00:00:00 UTC 起)微秒数
 * 
 * @return uint64_t 
 */
uint64_t getCurrentTimestampUs();




/**
 *! @brief 计算int a/b 百分比
 * 
 * @param a 分子
 * @param b 分母
 * @return double  a/b的百分比
 */
double calculatePercentage(const int a, const int b);


#endif  // COMMON_H